<template>
    <div class="discover">
        <!-- 轮播图 -->
        <Banner :banners="banners"/>
        <!-- 推荐歌单 -->
        <Personalized :personalized="personalized"/>
        <!-- 最新MV -->
        <NewMv :newmv="newmv"/>
        <!-- 最新音乐 -->
        <RecNewSong :newsong="newsong"/>
    </div>
</template>
<script>
import Banner from './Childcomps/Banner.vue'
import Personalized from './Childcomps/Personalized.vue';
import NewMv from './Childcomps/NewMv.vue';
import RecNewSong from './Childcomps/RecNewSong.vue';
export default {
    name: "",
    data() {
        return {
            // 轮播图数据
            banners:[],
            // 获取推荐歌单
            personalized:[],
            // mv
            newmv:[],
            //每日推荐新音乐
            newsong: []
        };
    },
    created() {
        // 发送请求获取banner信息
        this.getBannerBy();
        // 获取推荐歌单的信息
        this.getPersonalizedBy();
        // 获取MV信息
        this.getNewmvBy();
        // 获取推荐音乐
        this.getNewSongBy();
    },
    
    methods: {
        async getBannerBy(){
            let resBanner = await this.$API.discover.getBanner();
            if(resBanner.code == 200){
                this.banners = resBanner.banners;
            }
        },
        async getPersonalizedBy(){
            let resPersonalized = await this.$API.discover.getPersonalized();
            if(resPersonalized.code == 200){
                this.personalized = resPersonalized.result;
            }
        },
        async getNewmvBy(){
            let resMv =  await this.$API.discover.getNewMV();
            console.log(resMv)
            if(resMv.code == 200){
                this.newmv = resMv.result;

            }
        },
        async getNewSongBy(){
            let resSong =  await this.$API.discover.getNewSong();
            if(resSong.code == 200){
                this.newsong = resSong.result
            }
        }
    },
    
    components: { Banner, Personalized, NewMv, RecNewSong }
}
</script>
<style lang="less" scoped>
    
</style>